/*
 * Cute4jCommon.cpp  0.4.0 / Nov 14, 2010
 *
 * Copyright (c) 2010-2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#include "Cute4jCommon.h"

// Cute4jCommon :: Includes. ---------------------------------------------------

#ifdef USE_PLATFORM_CODE
  #include "Cute4jPlatform.h"
#else
  #include <QApplication>
  #include <QMessageBox>
#endif // USE_PLATFORM_CODE

BEGIN_NAMESPACE_CUTE4J

// Cute4jCommon :: Functions. --------------------------------------------------

/*!
 * \brief Shows the error message.
 *
 * \param title the title
 * \param message the message
 */
void ErrorMessage(const char *title, const char *message)
{
  #ifdef USE_PLATFORM_CODE
    Cute4j::Platform::ErrorMessage(title, message);
  #else
    if (!qApp) {
      int argc = 0;
      QApplication app(argc, 0);
      QMessageBox::critical(0, title, message, QMessageBox::Ok, 0);
    } else {
      QMessageBox::critical(0, title, message, QMessageBox::Ok, 0);
    }
  #endif // USE_PLATFORM_CODE
}

/*!
 * \brief Shows the warning message.
 *
 * \param title the title
 * \param message the message
 */
void WarningMessage(const char *title, const char *message)
{
  #ifdef USE_PLATFORM_CODE
    Cute4j::Platform::WarningMessage(title, message);
  #else
    if (!qApp) {
      int argc = 0;
      QApplication app(argc, 0);
      QMessageBox::warning(0, title, message, QMessageBox::Ok, 0);
    } else {
      QMessageBox::warning(0, title, message, QMessageBox::Ok, 0);
    }
  #endif // USE_PLATFORM_CODE
}

/*!
 * \brief Shows the information message.
 *
 * \param title the title
 * \param message the message
 */
void InformationMessage(const char *title, const char *message)
{
  #ifdef USE_PLATFORM_CODE
    Cute4j::Platform::InformationMessage(title, message);
  #else
    if (!qApp) {
      int argc = 0;
      QApplication app(argc, 0);
      QMessageBox::information(0, title, message, QMessageBox::Ok, 0);
    } else {
      QMessageBox::information(0, title, message, QMessageBox::Ok, 0);
    }
  #endif // USE_PLATFORM_CODE
}

END_NAMESPACE_CUTE4J
